/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ServicesAccessData;

import DAO.*;
import POJO.*;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.cassandra.thrift.Cassandra;
import org.apache.cassandra.thrift.InvalidRequestException;
import org.apache.cassandra.thrift.UnavailableException;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import profiler.ProfilerLog;

/**
 *
 * @author ngochuy
 */
public class AdminImplProfiled implements Admin.Iface {

    private TTransport tr;
    private Cassandra.Client client;

    public AdminImplProfiled() {
        try {
            tr = new TFramedTransport(new TSocket(Common.Constants.HOST, Common.Constants.PORT));
            TProtocol proto = new TBinaryProtocol(tr);
            client = new Cassandra.Client(proto);
            tr.open();
            client.set_keyspace(Common.Constants.KEYSPACE);
        } catch (InvalidRequestException ex) {
            Logger.getLogger(UserImpl.class.getName()).log(Level.SEVERE, null, ex);
        } catch (TException ex) {
            Logger.getLogger(UserImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public boolean insertStatus(StatusPOJO status) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Insert Status");
        StatusDAO stt = StatusDAO.getInstance(client);
        boolean result = false;
        try {
            result = stt.insertStatus(status);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Insert Status");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean updateContentStatus(String statusID, String content) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Content Status");
        StatusDAO stt = StatusDAO.getInstance(client);
        boolean result = false;
        try {
            result = stt.updateContentStatus(statusID, content);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Update Content Status");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean updateTagsOnAStatus(String statusID, String tags) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Tags On A Status");
        StatusDAO stt = StatusDAO.getInstance(client);
        boolean result = false;
        try {
            result = stt.updateTagsOnAStatus(statusID, tags);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Update Tags On A Status");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public int updateTagsOnListStatus(List<String> listStatusID, String tags) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Tags On List Status");
        StatusDAO stt = StatusDAO.getInstance(client);
        int result = 0;
        try {
            result = stt.updateTagsOnListStatus(listStatusID, tags);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Update Tags On List Status");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean updateIsPublicOnAStatus(String statusID, boolean state) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Is Public On A Status");
        StatusDAO stt = StatusDAO.getInstance(client);
        boolean result = false;
        try {
            result = stt.updateIsPublicOnAStatus(statusID, state);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Update Is Public On A Status");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public int updateIsPublicOnListStatus(List<String> listStatusID, boolean state) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Is Public On List Status");
        StatusDAO stt = StatusDAO.getInstance(client);
        int result = 0;
        try {
            result = stt.updateIsPublicOnListStatus(listStatusID, state);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Update Is Public On List Status");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean deleteStatus(String statusID) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Delete Status");
        StatusDAO stt = StatusDAO.getInstance(client);
        boolean result = stt.deleteStatus(statusID);
        ProfilerLog.getInstance("Admin").doEndLog("Delete Status");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public int deleteListStatus(List<String> listStatusID) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Delete List Status");
        StatusDAO stt = StatusDAO.getInstance(client);
        int result = stt.deleteListStatus(listStatusID);
        ProfilerLog.getInstance("Admin").doEndLog("Delete List Status");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public StatusPOJO selectStatusWithID(String statusID) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Select Status with ID");
        StatusDAO stt = StatusDAO.getInstance(client);
        StatusPOJO result = stt.selectStatusWithID(statusID);
        ProfilerLog.getInstance("Admin").doEndLog("Select Status with ID");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<StatusPOJO> selectStatusFromTag(String tagName) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Select Status From Tag");
        StatusDAO stt = StatusDAO.getInstance(client);
        List<StatusPOJO> result = stt.selectStatusFromTag(tagName);
        ProfilerLog.getInstance("Admin").doEndLog("Select Status From Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<String> getListPaging(int limit) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Get List Paging");
        StatusDAO stt = StatusDAO.getInstance(client);
        List<String> result = stt.getListPaging(limit);
        ProfilerLog.getInstance("Admin").doEndLog("Get List Paging");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<StatusPOJO> selectStatusFromPage(String startKey, int limit) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Select Status From Page");
        StatusDAO stt = StatusDAO.getInstance(client);
        List<StatusPOJO> result = stt.selectStatusFromPage(startKey, limit);
        ProfilerLog.getInstance("Admin").doEndLog("Select Status From Page");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<String> getListPagingOnATag(String tagName, int limit) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Get List Paging On A Tag");
        StatusDAO stt = StatusDAO.getInstance(client);
        List<String> result = stt.getListPagingOnATag(tagName, limit);
        ProfilerLog.getInstance("Admin").doEndLog("Get List Paging On A Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<StatusPOJO> selectStatusFromPageOnATag(String tagName, String startKey, int limit) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Select Status From Page On A Tag");
        StatusDAO stt = StatusDAO.getInstance(client);
        List<StatusPOJO> result = stt.selectStatusFromPageOnATag(tagName, startKey, limit);
        ProfilerLog.getInstance("Admin").doEndLog("Select Status From Page On A Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<StatusPOJO> searchStatusByContent(String keyWord, String _start, String _end, String filter) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Search Status By Content");
        StatusDAO stt = StatusDAO.getInstance(client);
        List<StatusPOJO> result = null;
        try {
            result = stt.searchStatusByContent(keyWord, _start, _end, filter);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Search Status By Content");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<StatusPOJO> searchStatusByTag(String keyWord, String _start, String _end, String filter) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Search Status By Tag");
        StatusDAO stt = StatusDAO.getInstance(client);
        List<StatusPOJO> result = null;
        try {
            result = stt.searchStatusByTag(keyWord, _start, _end, filter);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Search Status By Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<StatusPOJO> searchStatusByContentandTag(String keyWord, String tag, String _start, String _end, String filter) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Search Status By Content and Tag");
        StatusDAO stt = StatusDAO.getInstance(client);
        List<StatusPOJO> result = null;
        try {
            result = stt.searchStatusByContentandTag(keyWord, tag, _start, _end, filter);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Search Status By Content and Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public TagPOJO selectTagWithTagName(String tagName) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Select Tag With Tag Name");
        TagDAO tag = TagDAO.getInstance(client);
        TagPOJO result = tag.selectTagWithTagName(tagName);
        ProfilerLog.getInstance("Admin").doEndLog("Select Tag With Tag Name");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<TagPOJO> selectAllTag() throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Select All Tag");
        TagDAO tag = TagDAO.getInstance(client);
        List<TagPOJO> result = tag.selectAllTag();
        ProfilerLog.getInstance("Admin").doEndLog("Select All Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean updateIsPublicOnATag(String tagName, boolean state) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Is Public On A Tag");
        TagDAO tag = TagDAO.getInstance(client);
        boolean result = false;
        try {
            result = tag.updateIsPublicOnATag(tagName, state);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Update Is Public On A Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public int updateIsPublicOnListTag(List<String> listTagNane, boolean state) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Is Public On List Tag");
        TagDAO tag = TagDAO.getInstance(client);
        int result = 0;
        try {
            result = tag.updateIsPublicOnListTag(listTagNane, state);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Update Is Public On List Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean insertStatusIntoTag(String tagName, String statusID) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Insert Status Into Tag");
        TagDAO tag = TagDAO.getInstance(client);
        boolean result = tag.insertStatusIntoTag(tagName, statusID);
        ProfilerLog.getInstance("Admin").doEndLog("Insert Status Into Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean removeStatusFromTag(String tagName, String statusID) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Remove Status From Tag");
        TagDAO tag = TagDAO.getInstance(client);
        boolean result = tag.removeStatusInATag(tagName, statusID);
        ProfilerLog.getInstance("Admin").doEndLog("Remove Status From Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean insertTag(String tagName, boolean state) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Insert Tag");
        TagDAO tag = TagDAO.getInstance(client);
        boolean result = false;
        try {
            result = tag.insertTagInfo(tagName, state);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Insert Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean deleteTag(String tagName) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Delete Tag");
        TagDAO tag = TagDAO.getInstance(client);
        try {
            return tag.deleteTag(tagName);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Delete Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return false;
    }

    @Override
    public boolean deleteListTag(List<String> listTagName) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Delete List Tag");
        TagDAO tag = TagDAO.getInstance(client);
        try {
            return tag.deleteListTag(listTagName);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Delete List Tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return false;
    }

    @Override
    public List<TagPOJO> searchTags(String value, String _start, String _end, String filter) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Search Tags");
        TagDAO tag = TagDAO.getInstance(client);
        List<TagPOJO> result = null;
        try {
            result = tag.searchTags(value, _start, _end, filter);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Search Tags");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public UserPOJO selectInfoOfUser(String userID) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Select Info Of User");
        UserDAO user = UserDAO.getInstance(client);
        UserPOJO result = user.selectAllInfoOfAUser(userID);
        ProfilerLog.getInstance("Admin").doEndLog("Select Info Of User");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean updateIsBannedOnAUser(String userID, boolean state) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Is Banned On A User");
        UserDAO user = UserDAO.getInstance(client);
        boolean result = user.updateIsBannedOnAUser(userID, state);
        ProfilerLog.getInstance("Admin").doEndLog("Update Is Banned On A User");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public int updateIsBannedOnListUser(List<String> listUserID, boolean state) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Is banned on list user");
        UserDAO user = UserDAO.getInstance(client);
        int result = user.updateIsBannedOnListUser(listUserID, state);
        ProfilerLog.getInstance("Admin").doEndLog("Update Is banned on list user");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<UserPOJO> selectAllUserBanned() throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Select all user banned");
        UserDAO user = UserDAO.getInstance(client);
        List<UserPOJO> result = user.selectAllUserBanned();
        ProfilerLog.getInstance("Admin").doEndLog("Select all user banned");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public CounterPOJO getCounter() throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Get counter");
        CounterPOJO result = CounterDAO.getCounter(client);
        ProfilerLog.getInstance("Admin").doEndLog("Get counter");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean isAdminUser(String userID) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Is Admin User");
        UserDAO user = UserDAO.getInstance(client);
        boolean result = user.isAdminUser(userID);
        ProfilerLog.getInstance("Admin").doEndLog("Is Admin User");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean updateIsAdminOnAUser(String userID, boolean state) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Is Admin On A User");
        UserDAO user = UserDAO.getInstance(client);
        boolean result = user.updateIsAdminOnAUser(userID, state);
        ProfilerLog.getInstance("Admin").doEndLog("Update Is Admin On A User");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean updateIsAdminOnListUser(List<String> listUserID, boolean state) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Update Is admin on list User");
        UserDAO user = UserDAO.getInstance(client);
        boolean result = user.updateIsAdminOnListUser(listUserID, state);
        ProfilerLog.getInstance("Admin").doEndLog("Update Is admin on list User");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<UserPOJO> selectListAdminUser() throws TException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public List<userLog> getuserLog() throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Get user log");
        userLogDAO user = userLogDAO.getInstance(client);
        List<userLog> result = null;
        try {
            result = user.getuserLog();
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Get user log");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean setuserLog(String userID, String userName) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Set user log");
        userLogDAO user = userLogDAO.getInstance(client);
        boolean result = false;
        try {
            result = user.setuserLog(userID, userName);
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Set user log");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<favoriteLog> getfavoriteLog() throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Get favorite log");
        favoriteLogDAO fav = favoriteLogDAO.getInstance(client);
        List<favoriteLog> result = null;
        try {
            result = fav.getfavoriteLog();
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Get favorite log");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean setfavoriteLog(String userID, String userName, String statusID) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Set favorite log");
        favoriteLogDAO fav = favoriteLogDAO.getInstance(client);
        boolean result = false;
        try {
            result = fav.setfavoriteLog(userID, userName, statusID);
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Set favorite log");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public int getTotal_searchStatusByContent(String keyWord, String filter) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Get total search status by content");
        StatusDAO stt = StatusDAO.getInstance(client);
        int result = 0;
        try {
            result = stt.getTotal_searchStatusByContent(keyWord, filter);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Get total search status by content");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public int getTotal_searchStatusByTag(String keyWord, String filter) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Get total search status by tag");
        StatusDAO stt = StatusDAO.getInstance(client);
        int result = 0;
        try {
            result = stt.getTotal_searchStatusByTag(keyWord, filter);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Get total search status by tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public int getTotal_searchStatusByContentandTag(String keyWord, String tag, String filter) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Get total search status by content and tag");
        StatusDAO stt = StatusDAO.getInstance(client);
        int result = 0;
        try {
            result = stt.getTotal_searchStatusByContentandTag(keyWord, tag, filter);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Get total search status by content and tag");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public int getTotal_searchTags(String value, String filter) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Get total search tags");
        TagDAO stt = TagDAO.getInstance(client);
        int result = 0;
        try {
            result = stt.getTotal_searchTags(value, filter);
        } catch (Exception ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
        }
        ProfilerLog.getInstance("Admin").doEndLog("Get total search tags");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<StatusPOJO> selectAllStatus() throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Select all status");
        StatusDAO status = StatusDAO.getInstance(client);
        List<StatusPOJO> result = status.selectAllStatus();
        ProfilerLog.getInstance("Admin").doEndLog("Select all status");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<String> getListPagingUser(int limit) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Get List Paging User");
        UserDAO user = UserDAO.getInstance(client);
        List<String> result = user.getListPagingUser(limit);
        ProfilerLog.getInstance("Admin").doEndLog("Get List Paging User");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public List<UserPOJO> selectListUserFromPage(String startKey, int limit) throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("Select List User From Page");
        UserDAO user = UserDAO.getInstance(client);
        List<UserPOJO> result = user.selectListUserFromPage(startKey, limit);
        ProfilerLog.getInstance("Admin").doEndLog("Select List User From Page");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return result;
    }

    @Override
    public boolean All_cache() throws TException {
        ProfilerLog.getInstance("Admin").doStartLog("All cache");
        try {
            //Khởi tạo cache.
            List<String> listMem = new ArrayList<String>();
            (StatusDAO.getInstance(client)).createCache(listMem);
            (TagDAO.getInstance(client)).createCacheTag(listMem);
            (UserDAO.getInstance(client)).createCache(listMem);
            Memcached.set("ListMemId", Common.Constants.EXPIRE, listMem);
        } catch (UnavailableException ex) {
            Logger.getLogger(AdminImplProfiled.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
        ProfilerLog.getInstance("Admin").doEndLog("All cache");
        System.out.print(ProfilerLog.getInstance("Admin").dumpLogConsole());
        return true;
    }

    @Override
    public boolean setUserAdmin(String userID, String passWord) throws TException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean removeUserAdmin(String userID) throws TException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public UserAdminPOJO getUserAdmin(String userID) throws TException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public List<UserAdminPOJO> getListUserAdminPOJO() throws TException {
        throw new UnsupportedOperationException("Not supported yet.");
    }


}